home *** CD-ROM | disk | FTP | other *** search
/ The Games Machine 76 / XENIATGM66.iso / Indiana Jones / Indiana Jones.exe / RESOURCE / PREVIEW.GOB / cog_olv_jag3.cog < prev    next >
Text File  |  1999-11-15  |  10KB  |  435 lines

  1. # Jones 3D Cog Script
  2. #
  3. # olv_jag3.cog   
  4. #
  5. # [SCHOLL]
  6. #
  7. # (C) 1999 LucasArts Entertainment Company LLC. All Rights Reserved
  8. #
  9. # ========================================================================================
  10. symbols
  11.  
  12. message entered
  13. message    startup
  14. message    aievent
  15. message    arrivedwpnt
  16. message timer
  17.  
  18. thing    t_Jag        mask
  19. thing    t_Indy        local
  20.  
  21. int        n_eventType        local
  22. int        n_CrntAIMode     local
  23. int        n_OldAIMode     local
  24. int        n_Waypoint        local
  25. int        n_Temp            local
  26. int        b_Temp            local
  27. flex    f_Temp            local
  28. flex    f_DistToIndy    local 
  29. int        n_TimerID        local 
  30. int        b_OKToStopFlee=0 local
  31. int        n_idx            local
  32. int        b_WpntsActive=0    local
  33.  
  34. vector    v_IndyPos        local
  35. vector    v_JagPos        local
  36. vector    v_JagToIndy        local
  37. vector    v_IndyLook        local
  38. vector    v_Temp            local
  39.  
  40.  
  41.  
  42. # ===========================FLEE WAYPOINTS================================================
  43. int            NUM_FLEE_WAYPOINTS=56            local
  44. thing        t_Waypoint00
  45. thing        t_Waypoint01
  46. thing        t_Waypoint02
  47. thing        t_Waypoint03
  48. thing        t_Waypoint04
  49. thing        t_Waypoint05
  50. thing        t_Waypoint06
  51. thing        t_Waypoint07
  52. thing        t_Waypoint08
  53. thing        t_Waypoint09
  54. thing        t_Waypoint10
  55. thing        t_Waypoint11
  56. thing        t_Waypoint12
  57. thing        t_Waypoint13
  58. thing        t_Waypoint14
  59. thing        t_Waypoint15
  60. thing        t_Waypoint16
  61. thing        t_Waypoint17
  62. thing        t_Waypoint18
  63. thing        t_Waypoint19
  64. thing        t_Waypoint20
  65. thing        t_Waypoint21
  66. thing        t_Waypoint22
  67. thing        t_Waypoint23
  68. thing        t_Waypoint24
  69. thing        t_Waypoint25
  70. thing        t_Waypoint26
  71. thing        t_Waypoint27
  72. thing        t_Waypoint28
  73. thing        t_Waypoint29
  74. thing        t_Waypoint30
  75. thing        t_Waypoint31
  76. thing        t_Waypoint32
  77. thing        t_Waypoint33
  78. thing        t_Waypoint34
  79. thing        t_Waypoint35
  80. thing        t_Waypoint36
  81. thing        t_Waypoint37
  82. thing        t_Waypoint38
  83. thing        t_Waypoint39
  84. thing        t_Waypoint40
  85. thing        t_Waypoint41
  86. thing        t_Waypoint42
  87. thing        t_Waypoint43
  88. thing        t_Waypoint44
  89. thing        t_Waypoint45
  90. thing        t_Waypoint46
  91. thing        t_Waypoint47
  92. thing        t_Waypoint48
  93. thing        t_Waypoint49
  94. thing        t_Waypoint50
  95. thing        t_Waypoint51
  96. thing        t_Waypoint52
  97. thing        t_Waypoint53
  98. thing        t_Waypoint54
  99. thing        t_Waypoint55
  100.  
  101.  
  102. # ===========================SECTORS================================================
  103.  
  104. int            NUM_AUTO_FLEE_SECTORS=0     local
  105. sector        s_AutoFlee00            #
  106.  
  107. int            NUM_ACTIVATE_WPNT_SECTORS=1 local
  108. sector        s_ActivateWpnts00
  109.  
  110. int            NUM_DEACTIVATE_WPNT_SECTORS=1 local
  111. sector        s_DeactivateWpnts00
  112.  
  113.  
  114. # ===========================MISC CONSTANTS================================================
  115.  
  116. flex    MIN_FLEE_DISTANCE=2.6            local # distance jag wants to be from Indy before stopping fleeing
  117. flex    MAX_FLEEATTACK_DISTANCE=1.0            local # 
  118. flex    MIN_FLEE_TIME=4.0                local 
  119. flex    VARIABLE_FLEE_TIME=3.0            local
  120.  
  121. int        TIMER_ID_OKAY_TO_STOP_FLEE=0    local
  122. int        TIMER_ID_START_FLEE=1            local
  123.  
  124.  
  125.     flex        activatewaypoints            local
  126.     flex        deactivatewaypoints        local
  127.     int        f_fleetime                local
  128.     flex        setdisttoindy            local
  129.  
  130.  
  131.  
  132. end
  133. # ========================================================================================
  134.  
  135. code
  136. startup:
  137.     t_Indy=GetLocalPlayerThing();
  138.     return;
  139.  
  140. # ========================================================================================
  141. entered:
  142.     if (GetSourceRef() == t_Indy)
  143.     {
  144.         for (n_idx = 0; n_idx < NUM_ACTIVATE_WPNT_SECTORS; n_idx = n_idx + 1)
  145.         {
  146.             if (GetSenderRef() == s_ActivateWpnts00[n_idx])
  147.             {
  148.                 call ActivateWaypoints;
  149.             }
  150.         }
  151.         for (n_idx = 0; n_idx < NUM_DEACTIVATE_WPNT_SECTORS; n_idx = n_idx + 1)
  152.         {
  153.             if (GetSenderRef() == s_DeactivateWpnts00[n_idx])
  154.             {
  155.                 call DeactivateWaypoints;
  156.             }
  157.         }
  158.     }
  159.     else if (GetSourceRef() == t_Jag)
  160.     {
  161.         for (n_idx = 0; n_idx < NUM_AUTO_FLEE_SECTORS; n_idx = n_idx + 1)
  162.         {
  163.             if (GetSenderRef() == s_AutoFlee00[n_idx])
  164.             {
  165.                 AIFlee(t_Jag, t_Indy);
  166.             }
  167.         }
  168.     }
  169.     return;
  170.  
  171. # ========================================================================================
  172. aievent:
  173.     n_eventType        = GetParam(0);
  174.     n_CrntAIMode    = GetParam(1);
  175.     n_OldAIMode        = GetParam(2);    // only valid for certain n_eventType values
  176.  
  177.     if (n_eventType == 0x100)        // SITHAI_EVENTMODECHANGED
  178.     {
  179.         // if changing to flee mode
  180.         // turn on waypoints
  181.         if ( !BITTEST(n_OldAIMode, 0x800) && BITTEST(n_CrntAIMode, 0x800) )
  182.         {
  183.             AISetSubMode(t_Jag, 0x8000); // SITHAI_SUBMODECONTINUOUSWPNTMOTION
  184.             f_FleeTime = (MIN_FLEE_TIME + (Rand() * VARIABLE_FLEE_TIME));
  185.             SetTimerEx(f_FleeTime , TIMER_ID_OKAY_TO_STOP_FLEE, 0, 0 );
  186.             b_OKToStopFlee = 0;
  187.         }
  188.         // if exiting flee mode
  189.         // turn off waypoints
  190.         else if ( BITTEST(n_OldAIMode, 0x800) && !BITTEST(n_CrntAIMode, 0x800) )
  191.         {
  192.             call SetDistToIndy;
  193.         
  194.             // Consider restarting fleeing if Indy to close, but jag hasn't chose to surprise attack
  195.             if ( (f_DistToIndy < MIN_FLEE_DISTANCE) && !BITTEST(AIGetMode(t_Jag), 0x2))
  196.             {
  197.                 // Restart using timer to avoid nested mode changes
  198.                 SetTimerEx(0.01 , TIMER_ID_START_FLEE, 0, 0 );
  199.             }
  200.             else
  201.             {
  202.                 AIClearSubMode(t_Jag, 0x8000); // SITHAI_SUBMODECONTINUOUSWPNTMOTION
  203.             }
  204.         }
  205.     }
  206.  
  207. return;
  208.  
  209. # ========================================================================================
  210. timer:
  211.     t_Indy = GetLocalPlayerThing();
  212.  
  213.     n_TimerID = GetSenderID();
  214.     if (n_TimerID == TIMER_ID_OKAY_TO_STOP_FLEE)
  215.     {
  216.         b_OKToStopFlee = 1;
  217.     }
  218.     else if (n_TimerID == TIMER_ID_START_FLEE)
  219.     {
  220.         AIFlee(t_Jag, t_Indy);
  221.     }
  222.  
  223.     return;
  224.  
  225.  
  226. # ========================================================================================
  227. arrivedwpnt:
  228.     n_Waypoint = GetParam(0);
  229.  
  230.     call SetDistToIndy;
  231.  
  232.     if ( b_OKToStopFlee 
  233.          && (f_DistToIndy > MIN_FLEE_DISTANCE)
  234.          && BITTEST(AIGetMode(t_Jag), 0x800) // fleeing
  235.          && (RandBetween(0,100) < 90)
  236.          )
  237.     {
  238.         // StopThing before StopFlee so jaguar will turn to face indy
  239.         StopThing(t_Jag);
  240.         AIStopFlee(t_Jag);
  241.     }
  242.     else if ( b_OKToStopFlee 
  243.          && (f_DistToIndy < MAX_FLEEATTACK_DISTANCE)
  244.          && BITTEST(AIGetMode(t_Jag), 0x800) // fleeing
  245.          && (RandBetween(0,100) < 30)
  246.          )
  247.     {
  248.         AISetFireTarget(t_Jag, t_Indy);
  249.     }
  250.  
  251.     return;
  252.  
  253. # ========================================================================================
  254. SetDistToIndy:
  255.     v_IndyPos = GetThingPos(t_Indy);
  256.     v_JagPos = GetThingPos(t_Jag);
  257.  
  258.     f_DistToIndy = VectorDist(v_IndyPos, v_JagPos);
  259.  
  260.     return;
  261.  
  262. # ========================================================================================
  263. ActivateWaypoints:
  264.     if (b_WpntsActive)
  265.     {
  266.         return;
  267.     }
  268.  
  269.     b_WpntsActive = 1;
  270.     AISetInstinctWpntMode(t_Jag);
  271.  
  272.     for ( n_idx = 0; n_idx < NUM_FLEE_WAYPOINTS; n_idx = n_idx + 1 )
  273.     {
  274.         AISetWpnt(t_Waypoint00[n_idx], n_idx);
  275.         AISetWpntRank(n_idx, 20);
  276.     }
  277.  
  278.     AIConnectWpnts(0, 4);
  279.     AIConnectWpnts(0, 5);
  280.     AIConnectWpnts(0, 6);
  281.     AIConnectWpnts(1, 2);
  282.     AIConnectWpnts(1, 8);
  283.     AIConnectWpnts(1, 9);
  284.     AIConnectWpnts(2, 3);
  285.     AIConnectWpnts(2, 9);
  286.     AIConnectWpnts(2, 10);
  287.     AIConnectWpnts(3, 4);
  288.     AIConnectWpnts(3, 11);
  289.     AIConnectWpnts(4, 5);
  290.     AIConnectWpnts(4, 11);
  291.     AIConnectWpnts(4, 12);
  292.     AIConnectWpnts(5, 6);
  293.     AIConnectWpnts(5, 11);
  294.     AIConnectWpnts(5, 12);
  295.     AIConnectWpnts(5, 13);
  296.     AIConnectWpnts(5, 17);
  297.     AIConnectWpnts(6, 7);
  298.     AIConnectWpnts(6, 13);
  299.     AIConnectWpnts(7, 14);
  300.     AIConnectWpnts(7, 18);
  301.     AIConnectWpnts(8, 9);
  302.     AIConnectWpnts(8, 15);
  303.     AIConnectWpnts(8, 20);
  304.     AIConnectWpnts(8, 21);
  305.     AIConnectWpnts(9, 10);
  306.     AIConnectWpnts(9, 15);
  307.     AIConnectWpnts(10, 11);
  308.     AIConnectWpnts(10, 15);
  309.     AIConnectWpnts(11, 12);
  310.     AIConnectWpnts(11, 16);
  311.     AIConnectWpnts(12, 13);
  312.     AIConnectWpnts(12, 16);
  313.     AIConnectWpnts(12, 17);
  314.     AIConnectWpnts(13, 17);
  315.     AIConnectWpnts(13, 18);
  316.     AIConnectWpnts(14, 18);
  317.     AIConnectWpnts(14, 19);
  318.     AIConnectWpnts(15, 16);
  319.     AIConnectWpnts(15, 21);
  320.     AIConnectWpnts(15, 22);
  321.     AIConnectWpnts(17, 18);
  322.     AIConnectWpnts(17, 23);
  323.     AIConnectWpnts(18, 19);
  324.     AIConnectWpnts(18, 23);
  325.     AIConnectWpnts(18, 24);
  326.     AIConnectWpnts(19, 25);
  327.     AIConnectWpnts(20, 21);
  328.     AIConnectWpnts(20, 26);
  329.     AIConnectWpnts(21, 22);
  330.     AIConnectWpnts(21, 26);
  331.     AIConnectWpnts(21, 30);
  332.     AIConnectWpnts(22, 26);
  333.     AIConnectWpnts(22, 30);
  334.     AIConnectWpnts(23, 24);
  335.     AIConnectWpnts(24, 25);
  336.     AIConnectWpnts(24, 28);
  337.     AIConnectWpnts(25, 28);
  338.     AIConnectWpnts(25, 29);
  339.     AIConnectWpnts(26, 30);
  340.     AIConnectWpnts(26, 34);
  341.     AIConnectWpnts(27, 28);
  342.     AIConnectWpnts(27, 32);
  343.     AIConnectWpnts(27, 54);
  344.     AIConnectWpnts(28, 29);
  345.     AIConnectWpnts(28, 32);
  346.     AIConnectWpnts(28, 33);
  347.     AIConnectWpnts(29, 32);
  348.     AIConnectWpnts(29, 33);
  349.     AIConnectWpnts(30, 31);
  350.     AIConnectWpnts(30, 34);
  351.     AIConnectWpnts(30, 35);
  352.     AIConnectWpnts(30, 36);
  353.     AIConnectWpnts(31, 35);
  354.     AIConnectWpnts(31, 36);
  355.     AIConnectWpnts(31, 37);
  356.     AIConnectWpnts(31, 38);
  357.     AIConnectWpnts(31, 54);
  358.     AIConnectWpnts(32, 33);
  359. #    AIConnectWpnts(32, 38); was causing local maximum at 45
  360.     AIConnectWpnts(32, 54);
  361.     AIConnectWpnts(32, 55);
  362.     AIConnectWpnts(33, 39);
  363.     AIConnectWpnts(34, 35);
  364.     AIConnectWpnts(35, 36);
  365.     AIConnectWpnts(35, 41);
  366.     AIConnectWpnts(36, 37);
  367.     AIConnectWpnts(36, 41);
  368.     AIConnectWpnts(37, 38);
  369.     AIConnectWpnts(37, 41);
  370.     AIConnectWpnts(37, 43);
  371.     AIConnectWpnts(37, 44);
  372.     AIConnectWpnts(38, 43);
  373.     AIConnectWpnts(38, 44);
  374.     AIConnectWpnts(38, 54);
  375.     AIConnectWpnts(38, 55);
  376.     AIConnectWpnts(39, 45);
  377.     AIConnectWpnts(39, 55);
  378.     AIConnectWpnts(40, 41);
  379.     AIConnectWpnts(40, 46);
  380.     AIConnectWpnts(40, 47);
  381.     AIConnectWpnts(41, 42);
  382.     AIConnectWpnts(41, 46);
  383.     AIConnectWpnts(42, 43);
  384.     AIConnectWpnts(42, 47);
  385.     AIConnectWpnts(43, 44);
  386.     AIConnectWpnts(43, 48);
  387.     AIConnectWpnts(44, 45);
  388.     AIConnectWpnts(44, 48);
  389.     AIConnectWpnts(44, 49);
  390.     AIConnectWpnts(45, 48);
  391.     AIConnectWpnts(45, 49);
  392.     AIConnectWpnts(46, 47);
  393.     AIConnectWpnts(46, 50);
  394.     AIConnectWpnts(46, 51);
  395.     AIConnectWpnts(47, 50);
  396.     AIConnectWpnts(47, 51);
  397.     AIConnectWpnts(48, 49);
  398.     AIConnectWpnts(48, 52);
  399.     AIConnectWpnts(48, 53);
  400.     AIConnectWpnts(49, 52);
  401.     AIConnectWpnts(49, 53);
  402.     AIConnectWpnts(50, 51);
  403.     AIConnectWpnts(52, 53);
  404.     
  405.     // Discourage fleeing into these areas
  406.     AISetWpntRank(46, 16);
  407.     AISetWpntRank(47, 16);
  408.     AISetWpntRank(48, 16);
  409.     AISetWpntRank(49, 16);
  410.  
  411.     AISetWpntRank(50, 12);
  412.     AISetWpntRank(51, 12);
  413.     AISetWpntRank(52, 12);
  414.     AISetWpntRank(53, 12);
  415.  
  416.  
  417.     return;
  418.  
  419. # ========================================================================================
  420. DeactivateWaypoints:
  421.     if (!b_WpntsActive)
  422.     {
  423.         return;
  424.     }
  425.  
  426.     b_WpntsActive = 0;
  427.     AIClearInstinctWpntMode(t_Jag);
  428.     StopThing(t_Jag);
  429.  
  430.     return;
  431.  
  432.  
  433. end
  434.  
  435.